< previous page page_204 next page >

Page 204
Date( )/Date$( )
The Date() function returns a variant of type Date. Date$() returns a ten-character string in the format mm-dd-yy. Heres an example:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub cmdDate_Click ()
   Me.Print "Date = " & Date
   Me.Print "Date$ = " & Date$
End Sub
Heres the output:
9f31265bb40b592b1929e18a47ab28e5.gif
3/24/95        ' Gets this from International Settings
            ' in the control panel
3-24-1995
Time( )/Time$( )
Time$() returns the current system time. Heres an example:
9f31265bb40b592b1929e18a47ab28e5.gif
sTime = Time$()
DatePart( )
DatePart() returns the specified part of a date variable. Use it to return the day, year, month, and so on. Heres an example:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub cmdDatePart_Click ()
   Dim dtDate As Date

   Me.Cls
   ' Get System Date/Time
   dtDate = Now

   Me.Print dtDate
   Print
   Me.Print DatePart("m", dtDate)
   Me.Print DatePart("d", dtDate)
   Me.Print DatePart("yyyy", dtDate)
   Me.Print DatePart("q", dtDate)
   Me.Print DatePart("w", dtDate)
End Sub

 
< previous page page_204 next page >

If you like this book, buy it!